#pragma once

#include <map>
#include <string>
#include <initializer_list>

using namespace std;

#include "topcvt_string.hpp"
#include "topcvt_policycontext.hpp"
#include "topcvt_cfg.hpp"
#include "topcvt_exprparser.hpp"
#include "topcvt_object.hpp"

namespace topcvt
{
    class PolicyHelper 
    {
    public: 
        static string getUnpackFieldValue(PolicyContext& ctx, FieldCfg& field, const string& expValue, const string& encoding = string());
        static string getPackFieldValue(PolicyContext& ctx, FieldCfg& field, const string& objVal, map<string, string>& atx, const string& encoding = string());
        static string executeExpression(PolicyContext& ctx, const string& expr, const string& cc=string());
        static void   checkValidRange(AttributeableCfg& e, const string& attr, std::initializer_list<std::string> allowValues);
        static void   checkIntRange(AttributeableCfg& e, const string& attr, int min, int max);
        static void   checkBooleanValue(AttributeableCfg& e, const string& attr);
    private:
        static string getName(AttributeableCfg& e);
		static string& execFunction(PolicyContext& ctx,const string& function,string& value);
    };

};